<?php

require "./function.php";
/**
 * @Author: Wherein
 * @Date: 2021-03-15 10:45
 * @covers 工厂方法模式
 */
interface Car
{
    public function name();
}


class Wuling implements Car
{
    public function name()
    {
        dd('五菱');
    }
}

class Tesla implements Car
{
    public function name()
    {
        dd('特斯拉');
    }
}

class Dazhong implements Car{
    public function name()
    {
        dd('大众');
    }
}

class CarFactory{
    // ==方法一==
    /**
     * 获取car
     * @author Wherein <wherein777@163.com>
     * @param [type] $carName
     * @return void
     * @date 2021-03-15 10:32
     */
    public static function getCar(){}
}

class WulingFactory{
    public function getCar()
    {
        return new Wuling();
    }
}

class TeslaFactory{
    public function getCar()
    {
        return new Tesla();
    }
}


// 调用
$wulingFactory = new WulingFactory();
$wulingModel = $wulingFactory->getCar();
$wulingModel->name();
